﻿#include "FITKCDInterface.h"
#include "FITKCDDataSolid.h"
#include "FITKCDDataFluid.h"
#include "FITKCDDataInlet.h"
#include "FITKCDDataOutlet.h"
#include "FITKCDMonitorSamplingPoint.h"
#include "FITKCDCfgPSetPhysical.h"
#include "FITKCDCfgPSetSwitch.h"
#include "FITKCDCfgCSetComputation.h"
#include "FITKCDCfgCSetBase.h"
#include "FITKCDCfgCSetPath.h"
#include "FITKCDPostprocess3DFixedWall.h"
#include "FITKCDPostprocess3DRigidBody.h"
#include "FITKCDPostprocess3DFLuid.h"

using namespace Interface;

QMutex FITKCDInterface::m_mutex;

FITKCDInterface* FITKCDInterface::_instance = nullptr;


FITKCDDataSolidManager* FITKCDInterface::getCDDataSolidManager()
{
	return _pSolidManager;
}

FITKCDDataFluidManager* FITKCDInterface::getCDDataFluidManager()
{
	return _pFluidManager;
}

FITKCDDataInletManager* FITKCDInterface::getCDDataInletManager()
{
	return _pInletManager;
}

FITKCDDataOutletManager* FITKCDInterface::getCDDataOutletManager()
{
	return _pOutletManager;
}

FITKCDMonitorSamplingPointManager* FITKCDInterface::getCDSamplingPointManager()
{
	return _pSamplingPointManager;
}

FITKCDCfgPSetPhysicalManager* FITKCDInterface::getCDCfgPhysicalManager()
{
	return _pPhysicalManager;
}

FITKCDCfgPSetSwitchManager* FITKCDInterface::getCDCfgSwitchManager()
{
	return _pSwitchManager;
}

FITKCDCfgCSetComputationManager* FITKCDInterface::getCDCfgComputationManager()
{
	return _pComputationManager;
}

FITKCDCfgCSetBaseManager* FITKCDInterface::getCDCfgBaseManager()
{
	return _pBaseManager;
}

FITKCDCfgCSetPathManager* FITKCDInterface::getCDCfgPathManager()
{
	return _pPathManager;
}

FITKCDPost3DFixedWallManager* FITKCDInterface::getCDPost3DFixedWallManager()
{
	return _pFixedWallManager;
}

FITKCDPost3DRigidBodyManager* FITKCDInterface::getCDPost3DRigidBodyManager()
{
	return _pRigidBodyManager;
}

FITKCDPost3DFLuidManager* FITKCDInterface::getCDPost3DFLuidManager()
{
	return _p3DFLuidManager;
}



void FITKCDInterface::initialize()
{
	_pSolidManager = new FITKCDDataSolidManager;
	_pFluidManager = new FITKCDDataFluidManager;
	_pInletManager = new FITKCDDataInletManager;
	_pOutletManager = new FITKCDDataOutletManager;
	_pSamplingPointManager = new FITKCDMonitorSamplingPointManager;
	_pPhysicalManager = new FITKCDCfgPSetPhysicalManager;
	_pSwitchManager = new FITKCDCfgPSetSwitchManager;
	_pComputationManager = new FITKCDCfgCSetComputationManager;
	_pBaseManager = new FITKCDCfgCSetBaseManager;
	_pPathManager = new FITKCDCfgCSetPathManager;
	_pFixedWallManager = new FITKCDPost3DFixedWallManager;
	_pRigidBodyManager = new FITKCDPost3DRigidBodyManager;
	_p3DFLuidManager = new FITKCDPost3DFLuidManager;
}

void FITKCDInterface::finalize()
{
	if (_pSolidManager)
	{
		delete _pSolidManager;
		_pSolidManager = nullptr;
	}
	if (_pFluidManager)
	{
		delete _pFluidManager;
		_pFluidManager = nullptr;
	}
	if (_pInletManager)
	{
		delete _pInletManager;
		_pInletManager = nullptr;
	}
	if (_pOutletManager)
	{
		delete _pOutletManager;
		_pOutletManager = nullptr;
	}
	if (_pSamplingPointManager)
	{
		delete _pSamplingPointManager;
		_pSamplingPointManager = nullptr;
	}
	if (_pPhysicalManager)
	{
		delete _pPhysicalManager;
		_pPhysicalManager = nullptr;
	}
	if (_pSwitchManager)
	{
		delete _pSwitchManager;
		_pSwitchManager = nullptr;
	}
	if (_pComputationManager)
	{
		delete _pComputationManager;
		_pComputationManager = nullptr;
	}
	if (_pBaseManager)
	{
		delete _pBaseManager;
		_pBaseManager = nullptr;
	}
	if (_pPathManager)
	{
		delete _pPathManager;
		_pPathManager = nullptr;
	}
	if (_pFixedWallManager)
	{
		delete _pFixedWallManager;
		_pFixedWallManager = nullptr;
	}
	if (_pRigidBodyManager)
	{
		delete _pRigidBodyManager;
		_pRigidBodyManager = nullptr;
	}
	if (_p3DFLuidManager)
	{
		delete _p3DFLuidManager;
		_p3DFLuidManager = nullptr;
	}
}


